Component({
	properties: {
		tabList: {
			type: Array,
			value: [
				{
					id: 1,
					url: "/pages/index/index", // 修复路径
					text: "首页",
					iconPath: "../../static/tabbar/home.png",
					selectedIcon: "../../static/tabbar/home_active.png",
					type: "switchTab",
				},
				{
					id: 2,
					url: "/pages/classify/classify", // 修复路径
					text: "分类",
					iconPath: "../../static/tabbar/classify.png",
					selectedIcon: "../../static/tabbar/classify_active.png",
					type: "switchTab",
				},
				{
					id: 3,
					url: "/pages/servers/servers", // 修复路径
					text: "团课专区",
					iconPath: "../../static/tabbar/servers.png",
					selectedIcon: "../../static/tabbar/servers_active.png",
					type: "switchTab",
				},
				{
					id: 4,
					url: "/pages/cms/cms", // 修复路径
					text: "商家",
					iconPath: "../../static/tabbar/business.png",
					selectedIcon: "../../static/tabbar/business_active.png",
					type: "switchTab",
				},
				{
					id: 5,
					url: "/pages/my/my", // 修复路径
					text: "我的",
					iconPath: "../../static/tabbar/my.png",
					selectedIcon: "../../static/tabbar/my_active.png",
					type: "switchTab",
				},
			], // 传入的导航栏数据
		},
		selectedColor: {
			type: String,
			value: "#62CB81", // 默认选中颜色
		},
		unselectedColor: {
			type: String,
			value: "#000", // 默认未选中颜色
		},
		currentIndex: {
			type: Number,
			value: 0, // 当前选中的索引
		},
	},
	methods: {
		onTabChange(event) {
			const index = event.detail;
			const target = this.properties.tabList[index];
			if (this.properties.currentIndex === index) return;
			wx.reLaunch({
				url: target.url,
			});
		},
	},
});
